# -*- coding: utf-8 -*-
"""
利用递归函数画一个英国尺子,时间复杂度为O(2**N)
"""


def draw_line(tick_length: int, tick_label: str = ''):
    """Draw one line with given tick length(followed by optional label)."""
    line = '-' * tick_length
    if len(tick_label) > 0:
        line += ' ' + tick_label
    print(line)


def draw_interval(center_length: int):
    """Draw tick interval based upon a central tick length."""
    if center_length > 0:  # stop when length drops to 0
        draw_interval(center_length - 1)  # recursively draw top ticks
        draw_line(center_length)  # draw center tick
        draw_interval(center_length - 1)  # recursively draw bottom ticks


def draw_ruler(num_inches: int, major_length: int):
    """Draw English ruler with given number of inches, major tick length."""
    draw_line(major_length, '0')
    for j in range(1, 1 + num_inches):
        draw_interval(major_length - 1)
        draw_line(major_length, str(j))


if __name__ == "__main__":
    draw_ruler(2,5)
